<template>
  <el-dialog :title="'二级领导年奖统计明细'" :close-on-click-modal="false" :visible.sync="visible"
             @close="clearDataList()" width="85%" top="8vh">

    <el-table :data="dataList" stripe width="99%" style="height: 30vh" class="avue-crud mb10">
      <el-table-column type="index" width="80" header-align="center" align="center" label="序号"></el-table-column>
      <el-table-column prop="ryXm" label="姓名" width="100"></el-table-column>
<!--      <el-table-column prop="ffDw" label="发放单位" width="120"></el-table-column>-->
      <el-table-column prop="ryGzdw" label="工作单位" ></el-table-column>
      <el-table-column prop="ryZwgz" label="职务"></el-table-column>
      <el-table-column prop="ryXzjb" label="职级" width="160"></el-table-column>
      <el-table-column align="center" label="起始时间" width="120">
        <template slot-scope="scope">
          {{$moment(scope.row.llKssj).format("yyyy-MM")}}
        </template>
      </el-table-column>
      <el-table-column align="center" label="结束时间" width="120">
        <template slot-scope="scope">
          {{$moment(scope.row.llJssj).format("yyyy-MM")}}
        </template>
      </el-table-column>
      <el-table-column prop="jjJe" label="金额" width="200"></el-table-column>
    </el-table>


    <el-table :data="dataGrjc" stripe border width="99%" style="height: 30vh" class="avue-crud mb10">
      <el-table-column type="index" width="80" header-align="center" align="center" label="序号"></el-table-column>
      <el-table-column prop="jjxName" label="奖惩事项"></el-table-column>
      <!--<el-table-column prop="lx" label="类型"  width="80"></el-table-column>-->
      <el-table-column prop="jjJe" label="金额" header-align="center" align="right" width="200" :formatter="showSpecial"></el-table-column>

      <el-table-column label="奖惩时间" header-align="center" align="center"  width="220">
        <template slot-scope="scope">
          {{$moment(scope.row.jjDate).format("yyyy-MM-DD")}}
        </template>
      </el-table-column>
      <!--<el-table-column prop="jjSm" label="奖惩说明" ></el-table-column>-->
    </el-table>

    <span slot="footer" class="dialog-footer">
        <el-button @click="clearDataList" type="primary" plain>关闭</el-button>
    </span>

  </el-dialog>
</template>

<script>
import {getObj} from '@/api/jiangjin/jiangjinfpjjgrfppzmxb'
import {getGrjcByFfid} from  '@/api/jiangjin/jiangjingrjcjlb'

export default {
name: "fppzmxbDetail",
  data(){
    return{
      visible:false,
      dataList:[],
      dataForm: {
        id: 0,
        jjDeptId: '',
        jjDeptName: '',
        fpId: '',
        jjBh: '',
        fzId: '',
        fzName: '',
        deptCode: '',
        deptName: '',
        ryCode: '',
        ryName: '',
        ryZhiwei: '',
        ryZwjb: '',
        ryZwjbbh: '',
        config02: '',
        config03: '',
        jjzxId: '',
        jjzxMc: '',
        jjzxRq: '',
        jjxId: '',
        jjxMc: '',
        jjJe: '',
        jjJeDx: '',
        jjJeFp: '',
        jjJeJk: '',
        jjBz: '',
        jjYsje: '',
        jjGssm: '',
        jjGsjs: '',
        jjResumeList: '',
        createTime: '',
        editTime: '',
        createDeptId: '',
        createDeptName: '',
        createUserId: '',
        createUserName: '',
        editDeptId: '',
        editDeptName: '',
        editUserId: '',
        editUserName: '',
        dataState: '',
        tenantId: ''
      },
      dataGrjc:[]
    }
  },
  methods:{
    showSpecial(row, column, cellValue, index){
      ////console.log(row);
      if(row.lx === "惩罚"){
        return -1*cellValue;
      }else {
        return cellValue;
      }

      // return index + 1;
    },
    //初始化
    init(id){
      this.initForm();
      this.dataForm.id = id;
      this.visible=true;

      this.$nextTick(() => {
        getObj(this.dataForm.id).then(response => {
          this.dataForm = response.data.data
          ////console.log(this.dataForm);
          this.dataList = [];
          this.dataList = JSON.parse(this.dataForm.jjResumeList);
          // this.dataList =JSON.parse(JSON.stringify(this.dataForm.jjResumeList));

        //   this.dataList.push({
        //     ryXm:'唐艳秋',
        //     ryGzdw:'所属单位',
        //     ffDw:'',
        //     ryZwgz:'吉林业务部副总经理',
        //     ryXzjb:'二级副',
        //     llKssj:'2021-01-01T00:00',
        //     llJssj:'2021-12-31T12:00',
        //     jjJe:7578.95
        //   })

        });

        getGrjcByFfid(this.dataForm.id).then(res =>{
          this.dataGrjc = [];
          this.dataGrjc = res.data.data;
        })

      })

    },
    initForm(){
      this.dataForm ={
        id: 0,
          jjDeptId: '',
          jjDeptName: '',
          fpId: '',
          jjBh: '',
          fzId: '',
          fzName: '',
          deptCode: '',
          deptName: '',
          ryCode: '',
          ryName: '',
          ryZhiwei: '',
          ryZwjb: '',
          ryZwjbbh: '',
          config02: '',
          config03: '',
          jjzxId: '',
          jjzxMc: '',
          jjzxRq: '',
          jjxId: '',
          jjxMc: '',
          jjJe: '',
          jjJeDx: '',
          jjJeFp: '',
          jjJeJk: '',
          jjBz: '',
          jjYsje: '',
          jjGssm: '',
          jjGsjs: '',
          jjResumeList: '',
          createTime: '',
          editTime: '',
          createDeptId: '',
          createDeptName: '',
          createUserId: '',
          createUserName: '',
          editDeptId: '',
          editDeptName: '',
          editUserId: '',
          editUserName: '',
          dataState: '',
          tenantId: ''
      }
    },
    //取消
    clearDataList(){
      this.initForm();
      this.dataList = [];
      this.visible = false;
    },
  }
}
</script>

<style scoped>

</style>
